// pages/person/withdrawCash/withdrawHistory.js
const httpUtils = require('../../../utils/httpUtils')
const ui = require('../../../utils/ui')

Page({

  data: {
    lists: [],
    page: 1
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.requestList();
  },
  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {
    this.setData({
      page: 1
    });
    this.requestList();
    wx.stopPullDownRefresh();
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {
    this.setData({
      page: this.data.page + 1
    });
    this.requestList();
  },
  //请求列表
  requestList() {
    let obj = {
      method: 'GET',
      url: '/user/' + wx.getStorageSync('USERDATA').platformId + '/exchanges',
      showLoading: true,
      data: {
        page: this.data.page,
        size: 20,
        exchangeType: '提现'
      }
    }
    httpUtils.request(obj).then(res => {
      if (this.data.page == 1) {
        this.setData({
          cellsTwo: []
        });
      }
      const {
        lists = []
      } = this.data;
      res.data.userExchangeInfos.forEach(function (item, index) {
        lists.push(item);
      });
      this.setData({
        lists
      });
    }).catch(err => {
      console.log(err)
    });
  }
})